<template>
  <div class="father">
    <to-back class="to_back" :title="'商品列表'" @update-page="updatePage"></to-back>
    <div class="father2">
      <div class="box_card" style="background-color:#F9F9F9 ">
        <!-- 商品状态选择 -->
        <div class="box_goods">
          <el-button v-for="item in goodsStatus" :key="item.id" class="goods_state" @click="hadleStatus(item.id)">
            {{ item.title }}(<span class="btn_goodsStatus">{{ item.num }}</span
            >)
          </el-button>
        </div>
      </div>
      <!-- 筛选商品 -->
      <div class="filter">
        <div class="filter_header">
          <div class="left">
            <div></div>
            <i class="el-icon-search"></i>
            <span>筛选内容</span>
          </div>
          <div class="right">
            <div class="right_fl" @click="start">
              <!-- <i class="el-icon-arrow-down"></i> -->
              <!-- <div class="sanjiao"></div> -->
              <i :class="[rotate ? 'el-icon-arrow-down go' : ' el-icon-arrow-up up']"></i>
              <span>收起筛选</span>
            </div>
            <div class="right_fr">
              <ul>
                <li>查询结果</li>
                <li>高级检索</li>
              </ul>
            </div>
          </div>
        </div>
        <!-- 筛选的条件选择 -->
        <div class="filter_footer" v-show="rotate">
          <el-form :inline="true" :model="filterGoods" class="demo-form-inline">
            <el-form-item label="输入搜索">
              <el-input v-model="filterGoods.goodsName" placeholder="商品名称"></el-input>
            </el-form-item>
            <el-form-item label="商品分类">
              <el-select v-model="filterGoods.goodsClassfily" placeholder="请选择商品分类">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="商品品牌">
              <el-select v-model="filterGoods.goodsCommodity" placeholder="请选择品牌">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
              </el-select>
            </el-form-item>
          </el-form>
        </div>
      </div>

      <!-- 商品列表 -->
      <div class="goodsList">
        <div class="list_header">
          <div class="list_fl">
            <i class="el-icon-s-operation"></i>
            <span>数据列表</span>
          </div>
          <div class="list_fr">
            <div class="list_fr_fl">
              <ul>
                <li>修改基本信息</li>
                <li>修改商品详情</li>
              </ul>
            </div>
            <div class="list_fr_fr">
              <el-select class="oneselect" size="small" style="width:120px;" v-model="filterGoods.goodsCommodity" placeholder="显示条数">
                <el-option label="5条" value="shanghai"></el-option>
                <el-option label="10条" value="beijing"></el-option>
                <el-option label="15条" value="beijing"></el-option>
                <el-option label="20条" value="beijing"></el-option>
              </el-select>
              <el-select size="small" style="width:120px;" v-model="filterGoods.goodsCommodity" placeholder="排序方法">
                <el-option label="升序" value="shanghai"></el-option>
                <el-option label="降序" value="beijing"></el-option>
              </el-select>
            </div>
          </div>
        </div>
        <!-- <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55"> </el-table-column>
          <el-table-column label="日期" width="120">
            <template slot-scope="scope">{{ scope.row.date }}</template>
          </el-table-column>
          <el-table-column prop="name" label="姓名" width="120"> </el-table-column>
          <el-table-column prop="address" label="地址" show-overflow-tooltip> </el-table-column>
        </el-table> -->
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 商品状态
      goodsStatus: [],
      isCheck: false,
      current: 0,
      isDisplay: false,
      // 筛选
      filterGoods: {
        // 商品名称
        goodsName: '',
        // 商品货号
        goodsCodes: 123,
        // 商品分类
        goodsClassfily: [],
        // 商品品牌
        goodsCommodity: []
      },
      rotate: true,
      // 商品数据
      goodsList: [],
      // 当前页数
      currentPage: 1,
      // 数据条数
      pageSize: 5
    }
  },
  methods: {
    // 获取商品列表数据
    async getGoodsList() {
      const { data: res } = await this.$http.get('/goods/goodslist')
      console.log(res, '555')
    },
    start() {
      this.rotate = !this.rotate
      console.log(this.rotate)
    },
    // 刷新
    updatePage() {
      alert('父组件收到了')
    },

    // 商品状态
    async getGoodStatus() {
      const { data: res } = await this.$http.get('/goods/status')
      console.log(res, 'dd')
      this.goodsStatus = res.asideList
    },
    // btn的事件
    hadleStatus(id) {
      console.log(id)
    },
    // 收起筛选
    yincang() {
      this.isDisplay = !this.isDisplay
      console.log(this.isDisplay, 'display-1')
    }
  },
  created() {
    this.getGoodStatus()
    this.getGoodsList()
  }
}
</script>

<style lang="less" scoped>
.father {
  height: 100%;
  background-color: #f9f9f9;
}
.father2 {
  padding: 0 60px;
}
.to_back {
  color: #a599a5;
  border-bottom: 4px solid #ccc;
}

.btn_goodsStatus {
  color: red;
}
.el-button {
  margin: 20px 20px 20px 0;
}
.box_goods li {
  float: left;
  color: #000;
  height: 30px;
  width: 120px;
  margin: 20px 20px 20px 0;
  border: 1px solid #ccc;
  line-height: 30px;
  text-align: center;
}
.box_goods li a {
  color: #000;
}

// 筛选的部分的css
.filter {
  box-sizing: border-box;
  // height: 100px;
  // border: 1px solid #ccc;
  // background-color: pink;
  margin-bottom: 20px;

  .filter_header {
    box-sizing: border-box;
    display: flex;
    width: 100%;
    height: 50px;
    justify-content: space-between;
    background-color: #f3f3f3;
    border: 1px solid #ccc;
    padding: 15px 30px;
    align-items: center;
    .left {
      box-sizing: border-box;

      i {
        font-size: 20px;
        color: #666666;
      }
      span {
        padding-left: 5px;
        font-size: 12px;
      }
    }
    .right {
      color: #666666;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .right_fl {
        margin-right: 15px;
        color: #999999;
        span {
          font-size: 12px;
        }
      }
      li {
        float: right;
        border: 1px solid #ccc;
        height: 30px;
        width: 80px;
        line-height: 30px;
        text-align: center;
        font-size: 12px;
        background-color: #fff;
        &:hover {
          background-color: #eee;
        }
      }
      li:nth-child(1) {
        border-left: none;
      }
    }
  }
  .filter_footer {
    height: 70px;
    padding: 15px 30px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-top: none;
    background-color: #fff;
    .el-form-item {
      margin-right: 40px;
    }
  }
}

// 商品列表
.goodsList {
  border: 1px solid #ccc;
  .list_header {
    padding: 0 30px;
    border-bottom: 1px solid #ccc;
    background-color: #f3f3f3;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666666;
    .list_fl {
      i {
        font-size: 20px;
      }
      span {
        padding-left: 5px;
        font-size: 12px;
        color: #666666;
      }
    }
    .list_fr {
      display: flex;
      justify-content: space-between;

      .list_fr_fl {
        margin-right: 25px;
        li {
          float: right;
          border: 1px solid #ccc;
          height: 30px;
          width: 80px;
          line-height: 30px;
          text-align: center;
          font-size: 12px;
          background-color: #fff;
          &:hover {
            background-color: #eee;
          }
        }
        li:nth-child(1) {
          // border-left: none;
          margin-left: 10px;
        }
      }
      .list_fr_fr {
        .oneselect {
          margin-right: 10px;
        }
      }
    }
  }
}
</style>
